package br.com.millenium.service.cliente.processaction;

import lumis.doui.processaction.ProcessActionHandler;
import lumis.portal.PortalException;
import br.com.millenium.domain.manager.MilleniumManagerFactory;

@SuppressWarnings("rawtypes")
public class CheckDuplicateOcorrenciaProcessActionHandler extends ProcessActionHandler
{
	@Override
	public void processAction() throws PortalException 
	{
		String filialId     = (String)getParameter ( "filialId"     );
		String tpOcorrencia = (String)getParameter ( "tpOcorrencia" );
		java.util.Date dtOcorrencia = (java.util.Date)getParameter( "dtOcorrencia" );
		String ocorrenciaId = (String)(getParameter( "id"           ) == null ? "" : getParameter( "id" ));
		
		java.sql.Date sqlDate = new java.sql.Date(dtOcorrencia.getTime());
		
		if( MilleniumManagerFactory.getClienteManager().isDuplicateOcorrencia(filialId, tpOcorrencia, sqlDate, ocorrenciaId, transaction))
			throw new PortalException( "STR_OCORRENCIA_EXISTS;", getResource() );
	}
}
